<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>我的学分</title>
    <link rel="stylesheet" type="text/css" href="../../css/main.css" />
    <style>
        .credit {
            text-align: center;
            margin-top: 12px;
            border-top: 8px solid #d7d6d5;
            border-bottom: 3px solid #d7d6d5;
        }

        .fourty {
            margin-top: 17px;
            width: 51px;
            height: 61px;
        }

        .my {
            margin: 9px 0px;
            color: #727272;
            font-size: 17px;
        }

        .myself {
            color: #727272;
            font-size: 17px;
            margin-bottom: 23px;
        }

        .credit-grade {
            position: relative;
            border-bottom: 3px solid #d7d6d5;
        }

        .calendar {
            position: absolute;
            bottom: 23px;
            left: 29px;
            width: 39px;
            height: 41px;
        }

        .credit-sign {
            margin: 26px 0px 26px 93px;
            line-height: 15px;
            font-size: 17px;
            color: #727272;
        }

        .credit-add {
            color: #ea5718;
            margin-top: 8px;
        }

        .sign {
            position: absolute;
            right: 28px;
            bottom: 28px;
            width: 83px;
            height: 32px;
            border: 2px solid #ea5718;
            background: #fff;
            border-radius: 13px;
            color: #ea5718;
        }

        .sign1 {
            position: absolute;
            right: 28px;
            bottom: 28px;
            width: 83px;
            height: 32px;
            border: 2px solid #a9a9a9;
            background: #fff;
            border-radius: 13px;
            color: #a9a9a9;
        }

        .key {
            position: absolute;
            left: 24px;
            width: 49px;
            height: 32px;
        }

        .credit-two {
            position: absolute;
            width: 30px;
            height: 37px;
            left: 31px;
            bottom: 20px;
        }

        .creditexplain {
            height: 73px;
            line-height: 73px;
            padding-left: 23px;
            font-size: 17px;
            color: #727272;
            position: relative;
        }

        .jiantou {
            position: absolute;
            right: 28px;
            top: 26px;
            width: 14px;
            height: 22px;
        }

        .credit-explain {
            height: 53px;
            margin-right: 1px;
            background: #e9e8e7;
            line-height: 53px;
            padding-left: 23px;
            color:rgba(114,114,114,1);
        }

        .shuoming {
            padding: 10px;
            color: #c1c1c1;
            font-size: 13px;
            word-wrap: break-word;
        }
    </style>
</head>

<body>
    <div id="vm">
            <div class="credit">
                <img src="../../image/login/60.png" alt="" class="fourty" onclick="CloseWin()">
                <div class="my">
                    我的学分
                </div>
                <div class="myself">
                    {{score}}
                </div>
            </div>
            <div class="credit-grade">
                <img src="../../image/login/calendar.png" alt="" class="calendar">
                <div class="credit-sign">每日签到
                    <div class="credit-add">
                        +&nbsp;&nbsp;{{signscore}}
                    </div>
                </div>
                <button class="sign"  v-if="!issignflag"  @click="YiQianDaoWin()">
                  签到
                </button>
                <button class="sign1" v-else>
                  已签到
                </button>
            </div>
            <div class="credit-grade">
                <img src="../../image/login/27-1.png" alt="" class="credit-two">
                <div class="credit-sign">分享学学
                    <div class="credit-add">
                        +&nbsp;&nbsp;{{shareappscore}}
                    </div>
                </div>
                <button class="sign" @click="YiShareAPPWin()">
                  分享
                </button>
            </div>
            <div class="credit-grade">
                <img src="../../image/login/anjian.png" alt="" class="key">
                <div class="credit-sign">分享视频
                    <div class="credit-add">
                        +&nbsp;&nbsp;{{sharevideo}}
                    </div>
                </div>
                <button class="sign" @click="YiShareVideoWin()">
                    分享
                </button>
                <!-- <button class="sign" @click="YiShareVideoWin()" v-if="!issharevideoflag">
                    分享
                </button>
                <button class="sign1" v-else>
                    已分享
                </button> -->
            </div>
            <div class="credit-explain">
                学分获取途径说明
            </div>
            <div class="shuoming" v-html="contentget">
            </div>

            <div class="credit-explain">
                学分使用说明
            </div>
            <div class="shuoming" v-html="content">
            </div>
    </div>

</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/config.js"></script>
<script type="text/javascript" src="../../script/rest.js"></script>
<script type="text/javascript" src="../../script/vue.2.5.js"></script>
<script type="text/javascript" src="../../script/faskclick.js"></script>
<script type="text/javascript">
    var uid = $api.getStorage('uid');
    var session = $api.getStorage('session');

    var vm = new Vue({
            el: '#vm',
            data: {

                // 是否签到
                issignflag: false,
                // isshareappflag: false,
                // issharevideoflag: false,
                // 学分
                score: '0',
                contentget: '',
                content: '',
                // 签到一次的学分数
                signscore: '',
                shareappscore: '',
                sharevideo: '',

            },
            created: function() {
                var _this = this;
                apiready = function() {
                    _this.init();
                    api.parseTapmode();
                    if ('addEventListener' in document) {
                        document.addEventListener('DOMContentLoaded', function() {
                            FastClick.attach(document.body);
                        }, false);
                    }
                    api.addEventListener({
                        name:'resume'
                    }, function(ret, err){
                    _this.init();
                    });
                }
            },
            methods: {
                init: function() {
                    var _this = this;
                    if (uid) {
                        // 获取个人信息
                        _this.getuserinfo();
                        // 今天是否签到
                        _this.issign();
                        // 是否分享app
                        // _this.isshareapp();
                        // 是否分享视频
                        // _this.issharevideo();
                        // 获取学分规则
                        _this.getXueRule();
                    }
                    // api.addEventListener({
                    //     name: 'shareappsuccess'
                    // }, function(ret, err){
                    //   _this.getuserinfo();
                    //
                    // });
                    // api.addEventListener({
                    //     name: 'sharevideosuccess'
                    // }, function(ret, err){
                    //   _this.getuserinfo();
                    // });

                },
                getuserinfo() {
                    var _this = this;
                    new rest().get('getUserInfo').datae({
                        uid: uid
                    }).success(function(res) {
                        if (res.flag == 1) {
                            // 学分
                            _this.score = res.msg[0].score;
                        } else {
                            api.toast({
                                msg: res.msg[0],
                                duration: 2000,
                                location: 'middle'
                            });
                        }
                        // console.log(JSON.stringify(res))
                    }).error(function(err) {
                        console.log(JSON.stringify(err))
                    }).run()
                },
                issign() {
                    var _this = this;
                    new rest().get('isSign').datae({
                      uid: uid,
                      type:'1'
                    }).success(function(res) {
                        if (res.flag == 1) {
                            if (res.msg == '已签到') {
                                _this.issignflag = true;

                            } else {
                                _this.issignflag = false;
                            }
                        } else {
                            api.toast({
                                msg: res.msg,
                                duration: 2000,
                                location: 'middle'
                            });
                        }
                        // console.log(JSON.stringify(res))
                    }).error(function(err) {
                        console.log(JSON.stringify(err))
                    }).run()
                },
                // isshareapp() {
                //     var _this = this;
                //     new rest().get('isSign').datae({
                //       uid: uid,
                //       type:'3'
                //     }).success(function(res) {
                //         if (res.flag == 1) {
                //             if (res.msg == '已签到') {
                //                 _this.isshareappflag = true;
                //             } else {
                //                 _this.isshareappflag = false;
                //             }
                //         } else {
                //             api.toast({
                //                 msg: res.msg,
                //                 duration: 2000,
                //                 location: 'middle'
                //             });
                //         }
                //         console.log(JSON.stringify(res))
                //     }).error(function(err) {
                //         console.log(JSON.stringify(err))
                //     }).run()
                // },
                // issharevideo() {
                //     var _this = this;
                //     new rest().get('isSign').datae({
                //       uid: uid,
                //       type:'2'
                //     }).success(function(res) {
                //         if (res.flag == 1) {
                //             if (res.msg == '已签到') {
                //                 _this.issharevideoflag = true;
                //             } else {
                //                 _this.issharevideoflag = false;
                //             }
                //         } else {
                //             api.toast({
                //                 msg: res.msg,
                //                 duration: 2000,
                //                 location: 'middle'
                //             });
                //         }
                //         console.log(JSON.stringify(res))
                //     }).error(function(err) {
                //         console.log(JSON.stringify(err))
                //     }).run()
                // },
                getXueRule() {
                    var _this = this;
                    new rest().get('getRule').datae().success(function(res) {
                        if (res.flag == 1) {
                            _this.contentget = res.msg.content_get;
                            _this.content = res.msg.content;
                            _this.signscore = res.msg.sign_score;
                            _this.shareappscore = res.msg.share_app_score;
                            _this.sharevideo = res.msg.share_video;
                        } else {
                            api.toast({
                                msg: res.msg,
                                duration: 2000,
                                location: 'middle'
                            });
                        }
                        // console.log(JSON.stringify(res))
                    }).error(function(err) {
                        console.log(JSON.stringify(err))
                    }).run()
                },
                YiQianDaoWin: function() {
                    var _this = this;
                    // 签到
                    var _this = this;
                    var data={
                      _uid: uid,
                      session:session,
                      type:1
                    }
                    _this.share(data,'1')
                },
                YiShareAPPWin: function() {
                    var _this = this;

                    api.openFrame({
                        name: 'share',
                        url: '../VIP/share.html',
                        rect: {
                            x: 0,
                            y: 0,
                            w: 'auto',
                            h: 'auto'
                        },
                        pageParam:{
                          sharetitle:'学学app',
                          videoid:$api.getStorage('homevideoid'),
                        },
                        bounces: false,
                        bgColor: 'rgba(0,0,0,0.7)',
                        vScrollBarEnabled: true,
                        hScrollBarEnabled: true
                    });
                    api.addEventListener({
                        name: 'zhuanfa'
                    }, function(ret, err){
                      var data={
                        _uid: uid,
                        session:session,
                        type:3
                      }
                      _this.share(data,'3')
                    });


                },
                YiShareVideoWin: function() {
                    var _this = this;
                    // var data={
                    //     _uid: uid,
                    //     session:session,
                    //     type:2
                    //   }
                    api.openFrame({
                        name: 'share',
                        url: '../VIP/share.html',
                        rect: {
                            x: 0,
                            y: 0,
                            w: 'auto',
                            h: 'auto'
                        },
                        pageParam:{
                          sharetitle:$api.getStorage('homevideoname'),
                          videoid:$api.getStorage('homevideoid'),
                          // data:data,
                          // sharetype:'2'
                        },
                        bounces: false,
                        bgColor: 'rgba(0,0,0,0.7)',
                        vScrollBarEnabled: true,
                        hScrollBarEnabled: true
                    });
                    api.addEventListener({
                        name: 'zhuanfa'
                    }, function(ret, err){
                      var data={
                        _uid: uid,
                        session:session,
                        type:2
                      }
                      _this.share(data,'2')
                    });

                },
                share(data,type){
                  var _this = this;
                  new rest().get('share').datae(data).success(function(res) {
                      if (res.flag == 1) {
                        if(type=='1'){
                          _this.issignflag=true;
                          api.toast({
                              msg: '签到成功',
                              duration: 2000,
                              location: 'middle'
                          });
                          api.sendEvent({
                              name: 'signsuccess',
                          });
                          _this.getuserinfo();
                        }else if(type=='2'){
                          // _this.issharevideoflag=true;
                          api.toast({
                              msg: '分享成功',
                              duration: 2000,
                              location: 'middle'
                          });
                          api.sendEvent({
                              name: 'shareappsuccess',
                          });
                          _this.getuserinfo();
                        }else {
                          // _this.isshareappflag=true;
                          api.toast({
                              msg: '分享成功',
                              duration: 2000,
                              location: 'middle'
                          });
                          api.sendEvent({
                              name: 'sharevideosuccess',
                          });
                          _this.getuserinfo();
                        }
                      } else {
                          api.toast({
                              msg: res.msg,
                              duration: 2000,
                              location: 'middle'
                          });
                      }
                      console.log(JSON.stringify(res))
                  }).error(function(err) {
                      console.log(JSON.stringify(err))
                  }).run()
                }
            }

        })
        //关闭
    function CloseWin() {
        api.closeWin({
            name: 'verifymyselffram',
            url: 'verifymyself-fram.html',
        });

    }
</script>

</html>
